import { defineStore } from 'pinia'

const useUserStore = defineStore('user', {
  state: () => {
    return {
      token: localStorage.getItem('token')|| '',
      role: localStorage.getItem('role')|| '',
      userInfo: localStorage.getItem('userInfo')?
      JSON.parse(localStorage.getItem('userInfo')!):
      {}
    }
  },
  actions: {
    INIT_INFO(info:any) {
      this.token=info.token
      this.role=info.role
      this.userInfo=info.userInfo
    }
  }
})

export default useUserStore
